package jxls;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import model.Classes;
import model.Project;
import model.Target;
import net.sf.jxls.exception.ParsePropertyException;
import net.sf.jxls.transformer.XLSTransformer;

import org.apache.poi.openxml4j.exceptions.InvalidFormatException;

public class Test4 {

	public static void main(String[] args) throws ParsePropertyException, InvalidFormatException, IOException {

		String rootPath = System.getProperty("user.dir");
		String template = rootPath + "/template/template4.xls";  
		String generate = rootPath + "/generate/generate4.xls";  
  
		List<Classes> classess = new ArrayList<Classes>(); 
		for(int i = 0; i < 10; i++){
			
			Classes classes = new Classes();
			classes.setName("交通指南");
			classes.setAverage(4.4f);
			
			List<Project> projects = new ArrayList<Project>();
			for(int j = 0; j < 10; j++){
				
				Project project = new Project();
				project.setName("交通项目");
				project.setAverage(3.4f);
				
				List<Target> targets = new ArrayList<Target>();
				for(int k = 0; k < 10; k++){
					
					Target t = new Target();
					t.setCount(10);
					t.setFive(5);
					t.setFour(4);
					t.setThree(3);
					t.setTwo(2);
					t.setOne(1);
					t.setAverage(1.1f);
					t.setProblematic(2);
					targets.add(t);
				}
				project.setTarget(targets);
				projects.add(project);
			}
			classes.setProject(projects);
			classess.add(classes);
		}
		
        Map<String, Object> beanParams = new HashMap<String, Object>();
        beanParams.put("class", classess);
        XLSTransformer former = new XLSTransformer();  
//        Workbook wb = former.transformXLS(new FileInputStream(template), beanParams);
        former.transformXLS(template, beanParams, generate);
	}

}
